import  requests
from  bs4 import  BeautifulSoup

url = 'https://www.yn.gov.cn/'
headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36'

}
response = requests.get(url, headers=headers)
#查看响应码
print(response.status_code)

if response.status_code == 200:
    #创建BeautifulSoup对象
    soup = BeautifulSoup(response.text, 'html.parser')
    news_title = soup.findAll("a")
    for title in  news_title:
        text = title.text.strip()
        if text:
            print(text)